package com.bilicraft.plugin.kexue.commands;

import java.io.File;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

import com.bilicraft.plugin.kexue.ShellUser;

public class BiliCmdRm extends BiliCmd{
	public BiliCmdRm(){
		nofArgs = 1;
	}

	protected boolean doExec(CommandSender sender, Command cmd, String label, String[] args, ShellUser shellUser) {
		try{
			String cddir = shellUser.curdir+'/'+args[0];
			File fdir = new File(cddir);

			if(fdir.exists()){
				if(fdir.delete()){
					sender.sendMessage("File "+cddir+" removed success.");
				}else{
					sender.sendMessage("File "+cddir+" removed failed.");
				}
			}else{
				sender.sendMessage("Invalid path: "+cddir+".");
			}
			return true;
		}catch(Exception e){
			e.printStackTrace();
		}
		return false;
	}
}
